<?php
if(command("grammar")){
  $param="";
  for($i=2;$i<sizeOf($messageA);$i++){
    $param.=" ".$messageA[$i];
  }
  $param=" ".trim($param)." ";
  $gmatch=array();
  while(preg_match("/ a (.[aeiou]?)/",$param)){
    $gmatch[]=strpos($param," a ");
    $param=preg_replace("/ a (.[aeiou]?)/"," an $1",$param);
    echo "\n\npreg_match 1 in grammar: $param\n\n";
  }
  while(preg_match("/ an (.[bcdfghjklmnpqrstvwxyz]?)/",$param) and in_array(strpos(" an ",$param),$gmatch)!=true){
    $param=preg_replace("/ an (.[bcdfghjklmnpqrstvwxyz]?)/"," a $1",$param);
    echo "\n\npreg_match 2 in grammar: $param\n\n";
  }
  $param=trim($param);
  if(empty($param)){
    $param="You need to tell me what you want me to check the grammar of, $sender ;)";
  }
  SendCommand("PRIVMSG $channel :$param");
}
?>